<?php

namespace App\Requests\Label;

use App\Models\AdminRole;
use App\Models\Label;
use App\Requests\BaseRequest;

/**
 * @property int $id 该数据
 * @property string $name 名称
 * @property string $icon 图标
 * @property int $type 类型
 */
class StoreRequest extends BaseRequest
{
    /**
     * 定义规则信息
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|string|max:255|unique:' . Label::tableName() . ',name,' . ($this->id ?? 0) . ',id,is_delete,0,type,'.$this->type,
            'icon' => 'nullable|string|max:255',
            'type' => 'required|integer|min:1',
        ];
    }

    /**
     * 定义字段对应的名称
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'id'   => '该数据',
            'name' => '名称',
            'icon' => '图标',
            'type' => '类型',
        ];
    }
}
